package com.baor.utils;

import lombok.Data;

@Data
public class AjaxResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public AjaxResult(int code,String msg,T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> AjaxResult<T> success() {
        return new AjaxResult<T>(200,"操作成功",null);
    }
    public static <T> AjaxResult<T> success(T data) {
        return new AjaxResult<T>(200,"操作成功",data);
    }
    public static <T> AjaxResult<T> success(String msg,T data) {
        return new AjaxResult<T>(200,msg,data);
    }
    public static <T> AjaxResult<T> error() {
        return new AjaxResult<T>(500,"操作失败",null);
    }
    public static <T> AjaxResult<T> error(T data) {
        return new AjaxResult<T>(500,"操作失败",data);
    }
    public static <T> AjaxResult<T> error(String msg,T data) {
        return new AjaxResult<T>(500,msg,data);
    }
}
